local fuzhai = {}

-- 判断是否某界面通用方法
local function isXXX(args)
  local x, y = LuaAuxLib.FindMultiColor(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8])
  local b = false
  LuaAuxLib.TracePrint("1111", x, y)
  if x > 0 and y > 0 then
    b = true
    LuaAuxLib.TracePrint("### ", b, x, y)
  end
  return b, x, y
end

-- 点击出府按钮
fuzhai.tapChufu = function()
  LuaAuxLib.Tap(686, 34)
end

-- 点击华安（进入经营界面）
fuzhai.tapHuaAn = function(checkCanJingying)
  LuaAuxLib.TracePrint("点击华安")
  local args
  if checkCanJingying then
    args = {0, 521, 720, 812, "5B8BBE", "69|-22|72D5FE,79|2|0F121B,71|26|BEEDFD,73|49|171B24,-36|-41|908AD5,-29|-87|A1BAD7,70|-153|CCE5F0,-139|-151|CDE6F1,80|-151|2D3448", 0, 0.9}
  else
    args = {0, 584, 720, 882, "517DAC", "-4|-61|2F477D,6|55|2B2A2A,63|-42|0D1118,75|-63|74D6FE", 0, 0.9}
  end
  local b, x, y = isXXX(args)
  LuaAuxLib.TracePrint(b, x, y)
  if b then
    LuaAuxLib.Tap(x, y)
  end
  return b
end

-- 重置位置到左侧(华安的位置)
fuzhai.toLeft = function()
  local width = LuaAuxLib.GetScreenInfo(0)
  local height = LuaAuxLib.GetScreenInfo(1)
  LuaAuxLib.Swipe(20, height / 2, width - 20, height / 2)
end

-- 重置位置到右侧
fuzhai.toRight = function()
  local width = LuaAuxLib.GetScreenInfo(0)
  local height = LuaAuxLib.GetScreenInfo(1)
  LuaAuxLib.Swipe(width - 20, height / 2, 20, height / 2)
end

function QMPlugin.RegisterModule()
  LuaAuxLib.Modules = LuaAuxLib.Modules or {}
  LuaAuxLib.Modules.Jp_Fuzhai = fuzhai
end
